package net.wantongtech.xa.uploadbasicinfo.service;

import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.SCPClient;
import lombok.extern.slf4j.Slf4j;
import net.wantongtech.xa.uploadbasicinfo.dao.DealWithErrorRecordTransDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

/**
 * 处理错误的门架2类交易服务实现
 *
 * @author MaShibo
 * 日期 :  2020/2/1
 */
@Slf4j
@Service
public class DealWithErrorRecordTransService {


    @Resource
    private DealWithErrorRecordTransDao dealWithErrorRecordTransDao;


    public void process() {
        List<Long> msgList = dealWithErrorRecordTransDao.queryDealingRecordTransMsgId();
        log.info("共查询到{}条待处理的接收表记录", msgList.size());
        if (msgList.isEmpty()) {
            return;
        }
        msgList.forEach(msgId -> {

        });
    }


    private void processSingle(Long msgId) {
        Connection connection = new Connection("10.61.30.81", 22);
        try {
            connection.connect();

            boolean isAuthed = connection.authenticateWithPassword("root", "Huawei12#$");

            SCPClient scpClient = connection.createSCPClient();
            scpClient.get("");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
